package cn.rxls.community.service.impl;

import cn.rxls.community.dto.houses.HousesPageCommunityDTO;
import cn.rxls.community.entity.Houses;
import cn.rxls.community.enums.HouseStateEnum;
import cn.rxls.community.mapper.HousesMapper;
import cn.rxls.community.service.HousesService;
import cn.rxls.community.vo.houses.HousesVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 房屋(Houses)表服务实现类
 */
@Service("housesService")
public class HousesServiceImpl extends ServiceImpl<HousesMapper, Houses> implements HousesService {

    private final HousesMapper housesMapper;

    HousesServiceImpl(HousesMapper housesMapper) {
        this.housesMapper = housesMapper;
    }


    /**
     * 根据社区名称分页查询房屋信息
     *
     * @param dto 参数对象
     * @return 多个房屋信息
     */
    @Override
    public List<HousesVO> selectPageByRegion(HousesPageCommunityDTO dto) {
        //对分页参数进行处理
        dto.setPage((dto.getPage()-1)* dto.getSize());
        return housesMapper.selectPageByCommunity(dto.getPage(), dto.getSize(), dto.getId(), HouseStateEnum.IDLE.code);
    }
}

